﻿// (c) Copyright slimCODE Software Inc. - www.slimcode.com
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using SlimCode.Windows.Forms.Mobile;

namespace SlimCode.SlimPasswords
{
  // TODO: Rename
  public partial class EditNotesScreen : UserControl, IScreen
  {
    private IScreenHost m_host;

    public EditNotesScreen()
    {
      InitializeComponent();
    }

    public EditNotesScreen( string url, string notes )
      : this()
    {
      urlTextBox.Text = url;
      notesTextBox.Text = notes;
    }

    public string Notes 
    {
      get { return notesTextBox.Text; }
    }

    public string Url
    {
      get { return urlTextBox.Text; }
    }

    private void acceptMenuItem_Click( object sender, EventArgs e )
    {
      if( m_host != null )
      {
        m_host.HideScreen( DialogResult.OK );
      }
    }

    private void cancelMenuItem_Click( object sender, EventArgs e )
    {
      if( m_host != null )
      {
        m_host.HideScreen( DialogResult.Cancel );
      }
    }

    private void AnyControl_GotFocus( object sender, EventArgs e )
    {
      if( m_host != null )
      {
        Program.ToggleInputPanelIf( m_host.MainForm.MainInputPanel, ( sender is TextBox ) );
      }
    }

    #region IScreen Members

    public Control Control
    {
      get { return this; }
    }

    public Control DefaultFocus
    {
      get { return urlTextBox; }
    }

    public MainMenu Menu
    {
      get { return mainMenu; }
    }

    public string Title
    {
      get { return "slimPASSWORDS - More"; }
    }

    public bool Hiding( DialogResult result )
    {
      return true;
    }

    public void HidingChild( IScreen child, DialogResult result )
    {
    }

    public void Showing( IScreenHost host )
    {
      m_host = host;
    }

    #endregion
  }
}
